package com.pearl.table.demo.controller;

import cn.hutool.core.collection.ListUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pearl.table.demo.entity.AddressEntity;
import com.pearl.table.demo.entity.OrderDetailEntity;
import com.pearl.table.demo.entity.OrderEntity;
import com.pearl.table.demo.mapper.AddressMapper;
import com.pearl.table.demo.mapper.OrderMapper;
import com.pearl.table.demo.service.OrderDetailService;
import com.pearl.table.demo.service.OrderService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;

/**
 * <p>
 * 订单信息表 前端控制器
 * </p>
 *
 * @author 自动代码生成
 * @since 2024-01-24
 */
@RestController
@RequestMapping("/address")
@RequiredArgsConstructor
public class AddressController {

    private final OrderService orderService;

    private final OrderDetailService orderDetailService;

    private final OrderMapper orderMapper;

    private final AddressMapper addressMapper;

    @GetMapping("/page")
    public Object page() {
        return orderService.page(new Page<>(1, 10));
    }

    @GetMapping("/save")
    public Object save() {
        AddressEntity addressEntity = new AddressEntity();
        addressEntity.setName("湖南省长沙市岳麓区" );
        addressMapper.insert(addressEntity);
        return "操作成功";
    }

    @GetMapping("/remove")
    public Object remove(@RequestParam Long id) {
        addressMapper.deleteById(id);
        return "操作成功";
    }

    @GetMapping("/list")
    public Object list(@RequestParam Long id) {
        // 订单、地区表关联查询
        return orderMapper.selectOrderVOById(id);
    }
}